import pymysql

client = pymysql.connect(
    host='localhost',
    user='root',
    passwd='123456',
    port=3306,
    database='hugo',
    charset='utf8'
)
cursor = client.cursor()

user = [
    (1,'dadada'),
    (2,'xixixi'),
    (3,'huhu')
]
sql = 'insert into tt1 values (%s,%s)'
# try:
res = cursor.executemany(sql,user)
'''
user = [
    (1,'dahai')
    (1,'dahai')
    (1,'dahai')
]
sql = 'insert into tt1 values(%s,%s)'
cursor.executemany(sql,user)

user = [
    (1,'hhh)
    (1,'hhh)
    (1,'hhh)
]
sql = 'insert into tt1 values(%s,%s)'
cursor.executemany(sql,user)
user = [
    (1,''ppp)
    (1,''ppp)
    (1,''ppp)
    (1,''ppp)
]
sql = 'insert into tt1 values(%s,%s)'
cursor.executemany(sql,uer)
user = [
    (1,'mmm')
    (1,'mmm')
    (1,'mmm')
]
sql = 'insert into tt1 values(%s,%s)'
cursor.executemany(sql,user)
user = [
    (2,'hhh')
    (2,'hhh')
    (2,'hhh')
]
sql = 'insert into tt1 values(%s,%s)'
cursor.executemany(sql,user)

user = [
    (3,'uuu')
    (3,'uuu')
    (3,'uuu')
]
sql = 'insert into tt1 values(%s,%s)'
cursor.executemany(sql,user)
user = [
    (4,'yyy')
    (4,'yyy')
    (4,'yyy')
]
query = 'insert into tt1 values(6,'into')'
cursor.executemany(query,user)
user = [
    (3,'iidf')
    (3,'iidf')
    (3,'iidf')
]
query = 'insert into tt1 values(%s,%s)'
cursor,executemnay(sql,user)
user = [
    (3,'shehe')
    (3,'shehe')
    (3,'shehe')
    (3,'shehe')
]
sql = 'insert into tt1 values(%s,%s)'
cursor.executemany(sql,user)
user = [
    (6,'rrr')
    (6,'rrr')
    (6,'rrr')
    (6,'rrr')
]
sql = 'insert into tt1 values(%s,%s)'
cursor.executemany(sql,user)
user = [
    (888,'username')
    (888,'username')
    (888,'username')
    (888,'username')
]
sql = 'insert into tt1 values(%s,%s)'
cursor.ececutemany(sql,user)
user = [
    (666,'username')
    (666,'username')
    (666,'username')
]
sql = 'insert into tt1 values(%s,%s)'
cursor.executemany(sql,user)






























































'''

#     print(res)
#     client.commit()
#     query = 'select * from tt1'
#     cursor.execute(query)
#     print(cursor.fetchall())
# except Exception as e:
#     print('插入错误' %e)
# cursor.close()
# client.close()


#
# try:
#     for user1 in user:
#         # sql = 'insert into tt1 values (%s,"%s")'%(user1[0],user1[1])
#         sql = f'''insert into tt1 values ({user1[0]},'{user1[1]}')'''
#         print(sql)
#         cursor.execute(sql)
# except Exception as e:
#     # print(f'''"查询错误"{e}''')
#     print('错误%s%s'%(sql,e))
#     client.rollback()
# client.commit()
# query = "select * from tt1"
# cursor.execute(query)
# print(cursor.fetchall())
# cursor.close()
# client.close()
# query ='你好'
# query1 = '你坏'
# print('errer-%s-%s'%(query,query))
# print('err:%s %s'%(query,query))
# print('err:%s %s'%(query,query1))
# print('err:%s  %s'%(query,query1))
# print('err:%s   %s'%(query1,query))
# print('err:%s  %s'%(query,query1))
# print('err:%s    %s   %s'%(query,'name',query1))
# print('err:%s  %s   %s'%(query,query1,query))
# print('err:%s    %s     %s'%(query1,query,query1))
# print('err:%s    %s====%s'%(query1,query,11111111))
# print('err:%s ===> %s===> %s'%(query,query1,query1))
# print('err:%s===%s===%s'%(query,query1,query))
# print('err:%s== %s== %s'%(query1,query,888))
# print('err:%s   %s===%s---'%(9,2,query1))
# print('err: %s---%s===%s'%(query1,query,888888888888888))



